<%@ page contentType="text/html;charset=utf-8"%>
<%@ page
	import="java.io.*, java.sql.*, java.util.*, java.text.*, napal.*, util.*, napal.*"%>
<%@ page import="org.apache.ibatis.*"%>
<%@ page import="java.util.Date"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	request.setCharacterEncoding("utf-8");
%>
<img src="./img/logo.jpg"
				style="width: 310px; height: 120px;"><br>
		<script src="./bootstrap/js/bootstrap.js"></script>
<link href="./bootstrap/css/bootstrap.css" rel="stylesheet"
	media="screen">
<div class="well"><h2><p class="text-info">교수등록</p></h2></div>
	
<table class="table table-bordered">
<%String selectedCategory2 = request.getParameter("select02");
int de1=0;
if ("소프트웨어공학과".equals(selectedCategory2))
	de1 = 1;
else if ("정보통신공학과".equals(selectedCategory2))
	de1 = 2;
else if ("멀티미디어시스템공학과".equals(selectedCategory2))
	de1 = 3;
else if ("글로컬IT학과".equals(selectedCategory2))
	de1 = 4;
else if ("디지털컨텐츠학과".equals(selectedCategory2))
	de1 = 5;
else if ("신문방송학과".equals(selectedCategory2))
	de1 = 6;
else if ("경영학부".equals(selectedCategory2))
	de1 = 7;
else if ("사회과학부".equals(selectedCategory2))
	de1 = 8;
else if ("일어일본학과".equals(selectedCategory2))
	de1 = 9;
else if ("영어학과".equals(selectedCategory2))
	de1 = 10;
else if ("신학과".equals(selectedCategory2))
	de1 = 11;
else if ("사회복지학과".equals(selectedCategory2))
	de1 = 12;
else if ("중어중국학과".equals(selectedCategory2))
	de1 = 13;%>


	<%	
	String id = request.getParameter("id");
	String pw = request.getParameter("pw");
	String name = request.getParameter("name");
	String phone = request.getParameter("phone");
	String rank = request.getParameter("rank");
	String errMsg = "";
	if (id == null) {
		id = "";
		pw = "";
		name="";
		rank="";
		phone="";
		rank="";
	}	
	else if ("등록하기".equals(request.getParameter("cmd"))) {
		if(RentalHome.CheckUid(id).isEmpty()==false){
			errMsg="아이디가 중복됩니다";
		%>
				<font color="red"> <%=errMsg%>
				</font>
			<%}
		
		else if(request.getParameter("id")==""){
		errMsg="아이디를 정확히 입력하세요";
		%>
			<font color="red"> <%=errMsg%>
			</font>
		<%}
		
		else if(request.getParameter("pw").length()<4||request.getParameter("pw").length()>8){
			errMsg="비밀번호를 정확히 입력하세요";
		%>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		
		else if(request.getParameter("pw2").length()<4||request.getParameter("pw").length()>8){
			errMsg="확인 비밀번호를 정확히 입력하세요.";
		%>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		
		else if(request.getParameter("pw").equals(request.getParameter("pw2"))==false){
			errMsg="확인 비밀번호가 맞지않습니다.";
		%>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		
		else if(request.getParameter("name")==""){
			errMsg="이름을 정확히 입력하세요.";
		%>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		    
		  else if(de1==0){
			  errMsg="학과를 선택하세요.";
		  %>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		    
		    else if(request.getParameter("phone")==""){
		    	errMsg="연락처를 정확히 입력하세요.";
		    %>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		    else if(request.getParameter("rank")==""){
		    	errMsg="직급을 선택하세요.";
		    %>
		<font color="red"> <%=errMsg%>
			</font>
		    <%}
		
		    
		    else if("234".equals(request.getParameter("spw"))==false){
		    	errMsg="교수패스워드가 맞지 않습니다.";
		    %>
	<font color="red"> <%=errMsg%>
			</font>
		    <%} 
		    else{
		RentalHome.insertPUser(id, pw, name, de1,phone,rank);
									%>
				<script language=javascript>
       self.window.alert("회원가입 되었습니다.");
       location.href="Login.jsp";
    </script>
							<%	}}%>
							
							<html>
<head>
<!-- Bootstrap -->
<script src="./bootstrap/js/bootstrap.js"></script>
<link href="./bootstrap/css/bootstrap.css" rel="stylesheet"
	media="screen">
<meta http-equiv="Content-Type" content="text/html; charset=uft-8">
<title>성공회대학교 기자재대여시스템</title>

</head>
<body style="background:#FFFFFF url(./img/back.jpg) no-repeat fixed right bottom"><p>
<p align="center">
	<form method="post">
		<tr>
			<td>사용자 ID</td>
			<td><input type="text" name="id"  value="<%=id%>" ></td>
			<td></td>
		</tr>
		<tr>
			<td>패스워드</td>
			<td><input type="password"   name="pw"  maxlength="8"  value="<%=pw%>" ></td>
			<td>패스워드는 4~8자의 영문자나 숫자 또는 조합된 문자열이어야 합니다.</td>
		</tr>
		<tr>
			<td>패스워드 확인</td>
			<td><input type="password"   maxlength="8" name="pw2" ></td>
			<Td>확인을 위해 한번 더 입력해 주세요.</Td>
		</tr>
		<tr>
			<td>이름</td>
			<td><input type="text"  name="name" value="<%=name%>" ></td>
			<td>이름은 반드시 실명이어야 합니다.</td>
		</tr>
		<tr>
			<td>학과</td>
			<td><select name="select02">
									<OPTION VALUE='학과선택'>학과선택</OPTION>
									<OPTION VALUE="소프트웨어공학과">소프트웨어공학과</OPTION>
									<OPTION VALUE="정보통신공학과">정보통신공학과</OPTION>
									<OPTION VALUE="멀티미디어시스템공학과">멀티미디어시스템공학과</OPTION>
									<OPTION VALUE="글로컬IT학과">글로컬IT학과</OPTION>
									<OPTION VALUE="디지털컨텐츠학과">디지털컨텐츠학과</OPTION>
									<OPTION VALUE="신문방송학과">신문방송학과</OPTION>
									<OPTION VALUE="경영학부">경영학부</OPTION>
									<OPTION VALUE="사회과학부">사회과학부</OPTION>
									<OPTION VALUE="일어일본학과">일어일본학과</OPTION>
									<OPTION VALUE="영어학과">영어학과</OPTION>
									<OPTION VALUE="신학과">신학과</OPTION>
									<OPTION VALUE="사회복지학과">사회복지학과</OPTION>
									<OPTION VALUE="중어중국학과">중어중국학과</OPTION></select></td>
			<td></td>
		</tr>
		<tr>
			<td>연락처</td>
			<td><input type="text"  name="phone" value="<%=phone%>" ></td>
			<Td>형식(01012345678)</Td>
		</tr>
		<tr>
			<td>직급</td>
			<td><input type="radio" name="rank" value="학과장" style="width: 30;" >학과장&nbsp;&nbsp;&nbsp;
							<input type="radio" name="rank" value="교수" style="width: 30;" >학과교수&nbsp;&nbsp;&nbsp;
							<input type="radio" name="rank"value="외래교수" style="width: 30;" >외래교수&nbsp;&nbsp;&nbsp;
			<Td></Td>
		</tr>
		<tr>
			<td>교수패스워드</td>
			<td><input type="password"  name="spw"></td>
			<td>성공회대학교 교수임을 인증하기 위한 고유의 패스워드</td>
		</tr>
	</table>
				
<INPUT style="width: 90;" name="cmd" class="btn btn-inverse" TYPE="submit" VALUE="등록하기"> 
<a href="./Login.jsp"  class="btn btn-inverse" style="width: 90">이전화면</a>
		</form>
</body>
</html>